﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using SDT.CrawlSystem.MediaSrv;

namespace MDService
{
    public partial class MDService : ServiceBase
    {
        public MDService()
        {
            InitializeComponent();
        }       

        protected override void OnStop()
        {               // Viet undo comment from this body
            var n = 0;
            while (!container.StopAll() && n < 2)
            {
                n++;
                Thread.Sleep(60000);
            }

            if (n == 2)
                return;
            base.OnStop();
        }

        
        private MDContainer container = MDContainer.Instance;
       

        protected override void OnStart(string[] args)
        {  
            container.StartBegin();
            base.OnStart(args);
        }

        public void Run()
        {
            container.StartBegin();
        }

        
    }
}
